import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

import java.io.FileInputStream;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * Created by luojing on 2018/5/23.
 */
public class UploadHdfs {

	public static void main(String[] args) throws Exception {
		FileSystem fileSystem = FileSystem.get(URI.create(Contants.HDFS_URL),
				new Configuration(),"hadoop");
		Path src = new Path("D:/test.jpg");
		// 要上传到hdfs的目标路径
		Path dst = new Path("/usr/luojing");
		fileSystem.copyFromLocalFile(src, dst);

		fileSystem.close();
	}

}
